package com.olddriver.crm.web.controller;

import com.olddriver.crm.service.IAccidentBillItemService;
import com.olddriver.crm.service.IClientService;
import com.olddriver.crm.service.IInsuranceListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by 季节 on 2017/12/6
 */
@Controller
@RequestMapping("homepage")
public class HomePageController {
    @Autowired
    private IClientService clientService;
    @Autowired
    private IInsuranceListService insuranceListService;
    @Autowired
    private IAccidentBillItemService accidentBillItemService;

    @RequestMapping("masterpage")
    public String masterpage() {
        return "masterpage";
    }

    @RequestMapping("timeUI")
    public String timeUI() {
        return "timeUI";
    }

    @RequestMapping("getMessage")
    @ResponseBody
    public Map<String, Integer> getMessage() {
        HashMap<String, Integer> map = new HashMap<>();
        int unsignClient = clientService.getUnsignClient();
        int undealOrder = insuranceListService.getUndealOrder();
        int unpaidOrder = insuranceListService.getUnpaidOrder();
        int undealAccident = accidentBillItemService.getUndealAccident();
        map.put("client", unsignClient);
        map.put("insurance", undealOrder);
        map.put("paid", unpaidOrder);
        map.put("accident", undealAccident);
        return map;
    }
}
